package easy;

/**
 * @author admin
 * 2011. 执行操作后的变量值
 * 解题思路：直接遍历数据，遇到"--X"或者"X--"将结果减1，否则加1，最后返回结果
 */
public class LeeCode2011 {

    public int finalValueAfterOperations(String[] operations) {

        int res = 0;

        for (String operation : operations) {
            if (operation.equals("--X") || operation.equals("X--")){
                res--;
            }else {
                res++;
            }
        }
        return res;
    }

    public static void main(String[] args) {

        String[] res = new String[]{"--X","X++","X++"};
        System.out.println(new LeeCode2011().finalValueAfterOperations(res));
    }

}
